#ifndef FHE_CORE_SERIALIZER_REGISTERER_H
#define FHE_CORE_SERIALIZER_REGISTERER_H

#include <fhe/core/Serializer.h>
#include <fhe/core/FileSystem.h>

namespace fhe
{
  namespace core
  {
    template <typename T>
    class SerializerRegisterer : public boost::noncopyable
    {
    public:
      SerializerRegisterer( const std::string& name,
                            typename Serializer<T>::Serialize serialize,
                            typename Serializer<T>::Deserialize deserialize )
      {
        FileSystem::instance().addSerializer( ISerializer::Ptr(
          new Serializer<T>( name, serialize, deserialize ) ) );
      }
    };
    
    #define FHE_SERIALIZER( name, type, serialize, deserialize ) ::fhe::core::SerializerRegisterer<type> g_fhe_serializer_registerer_##name( #name, serialize, deserialize );
    #define FHE_SERIALIZER_TYPE( name ) ::fhe::core::SerializerRegisterer<name> g_fhe_serializer_registerer_##name( #name, &name::serialize, &name::deserialize );
  }
}

#endif
